let userMessageInput=document.getElementsByClassName("userMessageInput");
let messageBtn=document.getElementsByClassName("messageBtn")[0];
let QQ = /^\w+((-\w+)|(\.\w+))*@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
/*点击下一步按钮*/
messageBtn.onclick=function(){
    /*昵称*/
    if(userMessageInput[0].value===""){
        set("昵称不能为空");
    }else
    /*姓名*/
    if(userMessageInput[1].value===""){
        set("姓名不能为空");
    }else
    /*年龄*/
    if(!(userMessageInput[2].value<200&&userMessageInput[2].value>0)){
        set("请输入正确的年龄");
    }else
    /*邮箱*/
    if(!QQ.test(userMessageInput[3].value)){
        set("邮箱格式不正确");
    }else{
        NickNameT();
    }
}
function NickNameT(){
    $.ajax({
        url: '../user/updateAccount',
        type: 'post',
        data: {
            /*昵称*/
            nickname: userMessageInput[0].value,
            /*姓名*/
            realname: userMessageInput[1].value,
            /*年龄*/
            age: userMessageInput[2].value,
            /*邮箱*/
            email: userMessageInput[3].value,
            /*性别*/
            sex: userMessageInput[4].value,
            /*id*/
            id: sessionStorage.getItem("id")
        },
        success: function (data) {
            if(data.msg=="修改信息成功"){
                sessionStorage.setItem("nickname", userMessageInput[0].value);
                sessionStorage.setItem("realname", userMessageInput[1].value);
                sessionStorage.setItem("age", userMessageInput[2].value);
                sessionStorage.setItem("email", userMessageInput[3].value);
                sessionStorage.setItem("sex", userMessageInput[4].value);
                setTimeout(function () {
                    window.location.href = "../tooIndex";
                }, 1000)
            }else{
                set(data.msg);
            }
        }
    });
}
let tips=document.getElementsByClassName("tips")[0];
function set(i) {
    tips.innerHTML = i;
    tips.style.top = "56px";
    setTimeout(function () {
        tips.style.top = "-56px";
    }, 1000)
}